/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.testis.orm.refinedclasses;

import java.util.LinkedList;

import org.testis.orm.classes.T_label_filters;

/**
 * 
 * @author selcuk
 */
public class LabelFilterRefined {

    T_label_filters m_reference = new T_label_filters();

    public LabelFilterRefined() {
    }

    public LabelFilterRefined(T_label_filters ref) {
	setReference(ref);
    }

    private void setReference(T_label_filters ref) {
	if (ref == null) {
	    throw new NullPointerException();
	}
	m_reference = ref;
    }

    public int getId() {
	return m_reference.getId();
    }

    public String getName() {
	return m_reference.getName();
    }

    public void setName(String value) {
	m_reference.setName(value);
    }

    public String getFilterExpression() {
	return m_reference.getFilterExpression();
    }

    public void setFilterExpression(String value) {
	m_reference.setFilterExpression(value);
    }

    public void setFilterExpression(LinkedList<String> expList) {
	StringBuilder sb = new StringBuilder();
	if (expList != null) {
	    for (int i = 0; i < expList.size(); i++) {
		if (i == 0) {
		    sb.append(expList.get(i));
		} else {
		    sb.append("#$" + expList.get(i));
		}
	    }
	}
	setFilterExpression(sb.toString());
    }

    public LinkedList<String> parseFilterExpression() {
	LinkedList<String> result = new LinkedList<String>();
	String[] split = getFilterExpression().split("#$");
	for (int i = 0; i < split.length; i++) {
	    if (split[i].trim().length() > 0) {
		result.add(split[i].trim());
	    }
	}
	return result;
    }

    @Override
    public String toString() {
	return m_reference.getName();
    }
}
